
export const isThree = false;  //是否是三员审核
/**
 * 对象数组去重
 * @param {*} originalData 
 */
export const removeDuplicates = (originalData) => {
    let result, obj = {};
    result = originalData.reduce((cur, next) => {
        obj[next.key] ? "" : obj[next.key] = true && cur.push(next);
        return cur;
    }, []);
    return result;
};
/**
 * 获取浏览器url参数
 */
export const getRequest = function () {
    var url = location.href; //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.split("?")[1];
        var strs = str.split("&");
        for (var i = 0; i < strs.length; i++) {
            theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
        }
    }
    return theRequest;
}
/**
 * 判定是否为一个对象
 */
export function isObject(par) {
    return typeof par === 'object' && par && typeof par !== 'function';
}

/**
 * 对比数组获取交集
 */
export function getArrIntersection(array1, array2) {
    var result = [];
    for (var i = 0; i < array2.length; i++) {
        var obj = array2[i];
        var num = obj.id;
        var isExist = false;
        for (var j = 0; j < array1.length; j++) {
            var aj = array1[j];
            if (aj == num) {
                isExist = true;
                break;
            }
        }
        if (isExist) {
            result.push(obj);
        }
    }
    return result
}
/**
 * 计算产品剩余多少天
 */
export function computeProductTime(startTime, endTime) {
    var nowTimestamp = getTimeStamp(getNowDate());
    var startStamp = getTimeStamp(startTime)
    var endStamp = getTimeStamp(endTime)
    if(startStamp<=nowTimestamp &&endStamp>=nowTimestamp){
        var val = endStamp-nowTimestamp
    }
    if(startStamp>nowTimestamp){
        var val = endStamp-startStamp
    }
    var hour = parseInt(parseInt(val / 60) / 60);
    if (hour >= 24) {
        hour = parseInt(parseInt(val / 60) / 60) % 24
        var day = parseInt(parseInt(parseInt(val / 60) / 60) / 24 + 1)
        var time = day + "天";
    } else {
        time = "1天";
    }
    if (nowTimestamp > endStamp) {
        var val = nowTimestamp - endStamp
        if(val>86400){
            time = '0天'
        }
    }
    return time
}
/**
 * 字符串日期转时间戳
 * 
 */
export function getTimeStamp(date){
    var timestamp = Date.parse(date)/1000
    return timestamp
}
/**
 * 获取当前日期
 */
function getNowDate(){
    var now = new Date(),
    y = now.getFullYear(),
    m = now.getMonth() + 1,
    d = now.getDate(),
    x = y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d);
    return x
}
export function booleanConversion(data){
    switch (data) {
        case 0:
            return true
        default :
            return false
    }
}

export function numberConversion(data){
    switch (data) {
        case true:
            return 0
        default :
            return 1
    }
}